import QtQuick
import Gui.Global as G
import QtQuick.Controls.Fusion

Item {
    id: root
    property bool isMaximized: false
    required property Window dragWindow
    implicitWidth: childrenRect.width
    implicitHeight: childrenRect.height
    Row {
        width: childrenRect.width
        height: 30
        spacing: 5
        OperationBtn {
            id: minButton
            iconName: "msc.chrome-minimize"
            onClicked: {
                dragWindow.showMinimized();
                if (root.isMaximized) {
                    root.isMaximized = false;
                    maxRestoreButton.iconName = G.Font.msc.chrome_maximize;
                }
            }
            tipName: "最小化"
        }
        OperationBtn {
            id: maxRestoreButton
            iconName: "msc.chrome-maximize"
            tipName: root.isMaximized ? "" : "最大化"
            onClicked: {
                if (root.isMaximized) {
                    dragWindow.showNormal();
                    iconName = "msc.chrome-maximize";
                } else {
                    dragWindow.showMaximized();
                    iconName = "msc.chrome-restore";
                }
                root.isMaximized = !root.isMaximized;
            }
        }
        OperationBtn {
            iconName: "msc.chrome-close"
            onClicked: dragWindow.close()
            hoveredColor: "#FB7373"
            tipName: "关闭"
        }
    }
    component OperationBtn: IconButton {
        width: parent.height
        height: parent.height
        iconSize: parent.height - 10
        cursorShape: Qt.PointingHandCursor
    }
}
